/*
 * 컴파일을 위해 올려 놓은 소스 입니다.
 * 서버에 반영하지 마시고 다른국가에 적용할 경우 서버에 있는 class 를 카피해서 사용하십시오.
 * 
 */
/*
 * Created on 2004. 10. 4.
 *
 * To change the template for this generated file go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
package com.pushmsg.OmaOtaConf.OmaOtaObject;
 
import java.util.*;
/**
 * @author dgchun
 *
 * To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
public class MMS extends APPLICATION
{
	String name = null;
	String url = null;
	String country = null;
	String operator = null;
	String bearer = null;
	String nettype = null;
	
	private Hashtable profile = null;
	PXPHYSICAL physical = null;
	
	public MMS(String proxyid, String country, String op, String bearer, String nettype)
	{
		super.appid = "w4";
		super.proxyid = proxyid;
		//this.name = op+"-"+bearer+"-"+nettype;
		this.country = country;
		this.operator = op;
		this.bearer = bearer;
		this.nettype = nettype;		
	}
	
	public void setName(String name)
	{
		this.name = name;
	}
	
	private boolean getSetting()
	{
		String file = Constants.FILEPATH + country.toLowerCase() + "/" + operator + "_mms_" + bearer+ "_" + nettype + ".xml";
		ProfileReader pr = new ProfileReader(file);
		profile = pr.getProfile();
		if(profile==null)
			return false;		
		url = (String)profile.get("URL");
		return true;		
	}
	
	public int getData(byte[] buffer, int index)
	{
		if(getSetting()==false)
			return -1;
		int startPos = index;
		
		//<characteristic type="APPLICATION">
		buffer[index++] = (byte)0xC6;
		buffer[index++] = (byte)0x00; //switch to 
		buffer[index++] = (byte)0x01; //code page 01
		buffer[index++] = (byte)0x55; //type="APPLICATION"
		buffer[index++] = (byte)0x01;
		//<parm name="APPID" value="w4"/>
		buffer[index++] = (byte)0x87;
		buffer[index++] = (byte)0x36;
		buffer[index++] = (byte)0x06; //value=
		buffer[index++] = (byte)0x03; //start of inline string
		System.arraycopy(appid.getBytes(), 0, buffer, index, appid.length());
		index += appid.length();
		buffer[index++] = (byte)0x00; //end of inline string
		buffer[index++] = (byte)0x01; //end of parm
		//<parm name="TO-PROXY" value="xxx"/>
		buffer[index++] = (byte)0x87;
		buffer[index++] = (byte)0x39; //name="TO-PROXY"
		buffer[index++] = (byte)0x06; //value=
		buffer[index++] = (byte)0x03; //start of inline string
		System.arraycopy(proxyid.getBytes(), 0, buffer, index, proxyid.length());
		index += proxyid.length();
		buffer[index++] = (byte)0x00; //end of inline string
		buffer[index++] = (byte)0x01; //end of parm
		//<parm name="NAME" value="xxxx"/>
		buffer[index++] = (byte)0x87;
		buffer[index++] = (byte)0x07; //name="NAME"
		buffer[index++] = (byte)0x06; //value=
		buffer[index++] = (byte)0x03; //start of inline string
		System.arraycopy(name.getBytes(), 0, buffer, index, name.length());
		index += name.length();
		buffer[index++] = (byte)0x00; //end of inline string
		buffer[index++] = (byte)0x01; //end of parm		
		//<parm name="ADDR" value="xxxx"/>
		buffer[index++] = (byte)0x87;		
		buffer[index++] = (byte)0x34; //name="ADDR"
		buffer[index++] = (byte)0x06; //value=
		buffer[index++] = (byte)0x03; //start of inline string
		System.arraycopy(url.getBytes(), 0, buffer, index, url.length());
		index += url.length();
		buffer[index++] = (byte)0x00; //end of inline string
		buffer[index++] = (byte)0x01; //end of parm
		buffer[index++] = (byte)0x01; //end of characteristic with the attribute 'APPLICATTION'
		return index - startPos;
	}
}

